<?php
require_once(TEST_INTEGRATION_PATH . 'OrdersProducts.php');
require_once(TEST_DTO_PATH.'ProductDTO.php');
require_once(TEST_DTO_PATH.'OrderDTO.php');

class TestOfOrdersProductsLoad extends UnitTestCase {
	private $db;
	private $products;
	private $productDTO;
	private $orderDTO;
	
	function __construct() {
		$this->db = new Datasource(TEST_DB_SERVER, TEST_DB_DATABASE, TEST_DB_SERVER_USERNAME, TEST_DB_SERVER_PASSWORD);
		
		$this->productDTO = new ProductDTO;
		$this->productDTO->pid = 1;
		
		$this->orderDTO = new OrderDTO();
		$this->orderDTO->products = array($this->productDTO);
		$this->orderDTO->price = 299.99;
		$this->orderDTO->currency = "USD";
		$this->orderDTO->method = "cod";
		$this->orderDTO->cashier = "Donna";
		
		$this->products = new OrdersProducts();
	}
	
	function testOrdersProductsArray() {
		
		/* Create the dummy product based on the product in the database */
		$dummyOrdersProductsArray = array();
		
	    $dummyProduct =	array('id' => 1,
			              'category' => 4,
			              'name' => "Matrox G200 MMS",
			              'model' => "MG200MMS",
			              'image' => "matrox/mg200mms.gif",
			              'price' => 299.9900,
			              'qty' => 1,
			              'weight' => 23,
			              'final_price' => 299.9900,
			              'onetime_charges' => 0,
			              'tax_class_id' => 1,
							  'tax' => (int)0.0000,
							  'tax_description' => "FL TAX 7.0%",
			              'attributes' => "",
			              'attributes_values' => "",
			              'products_priced_by_attribute' => 0,
			              'product_is_free' => 0,
			              'products_discount_type' => 0,
			              'products_discount_type_from' => 0
						  );
						  

		array_push($dummyOrdersProductsArray, $dummyProduct);
		
		$this->assertEqual($dummyOrdersProductsArray, $this->products->load($this->orderDTO));
	}
}
?>
